<template>
	<view class="sosLayOut ">
		<view class="input">

			<view class="inputBg">
				<input class="filed" value="" placeholder-style="color:#666" :placeholder="$t('sosNotify.phoneOne')"
					@input="inputPhoneOne" />
			</view>
			<view class="inputBg">
				<input class="filed" value="" placeholder-style="color:#666" :placeholder="$t('sosNotify.phoneTwo')"
					@input="inputPhoneTwo" />
			</view>
			
			<!-- view class="inputBg">
				<input class="filed pwd" value="" placeholder-style="color:#666" placeholder="号码3" @input="inputPwd" />
			</view> -->
		</view>

		<view class="save-button" @click="toSaveSOS">
			{{$t('sosNotify.save')}}
		</view>
	</view>
</template>

<script>
	import { apiSetDeviceSOSNumber } from '../../api/device_api'; 
	import { encrypt } from '../../utils/encrypttools';
	import { i18nTool } from '../../utils/i18en';
import { getImei } from '../../utils/user_tools';
	export default {
		data() {
			return {
				phoneOne:'',
				phoneTwo:'',
				imei:""
			}
		},
		methods: {
		
			async toSaveSOS (){
				if (this.phoneOne.length == 0) {
					uni.showToast({
						icon:'error',
						title:i18nTool('sosNotify.err1'),
					})
					return;
				}
				if (this.phoneTwo.length == 0) {
					uni.showToast({
						icon:'error',
						title:i18nTool('sosNotify.err2'),
					})
					return;
				}

				const paramData = {
					phone1:this.phoneOne,
					phone2:this.phoneTwo,
					imei:this.imei
					
				}
	
				let res = await  apiSetDeviceSOSNumber(paramData)
				uni.showToast({
					title:i18nTool('sosNotify.suc'),
					icon:"success"
				})
				uni.navigateBack();
				
			},
			inputPhoneOne(e) {
				this.phoneOne = e.detail.value;
			},
			inputPhoneTwo(e) {
				this.phoneTwo = e.detail.value;
			},
		},
		async onLoad(){
			uni.setNavigationBarTitle({
				title:i18nTool("sosNotify.navTitle")
			})
			this.imei = getImei();
		} 
	}
</script>

<style lang="scss" scoped>
	.sosLayOut {
		.input {
			margin-top: 100rpx;

			.inputBg {
				margin: 40rpx 40rpx;
				border: 2rpx solid #BDBDBD;
				border-radius: 10rpx;
				height: 80rpx;
				align-items: center;

				.filed {
					height: 100%;
					padding-left: 30rpx;
					padding-right: 15rpx;
					color: #333;
					font-size: 28rpx;
				}
			}

		}

		.save-button {
			margin-left: 30rpx;
			margin-right: 30rpx;
			margin-top: 100rpx;
			height: 80rpx;
			color: #fff;
			background-color: #53786C;
			border-radius: 40rpx;
			@include flex-box-set(center);

		}
	}
</style>
